var jq = jQuery.noConflict();
jq(function(jq){
	jq.datepicker.regional['es']={
		closeText: 'Cerrar',
		prevText: '&#x3c;Ant',
		nextText: 'Sig&#x3e;',
		currentText: 'Hoy',
		monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
		monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
		'Jul','Ago','Sep','Oct','Nov','Dic'],
		dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
		dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Juv','Vie','S&aacute;b'],
		dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','S&aacute;'],
		weekHeader: 'Sm',
		dateFormat: 'dd/mm/yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	jq.datepicker.setDefaults(jq.datepicker.regional['es']);
});


window.history.forward(1);
document.onkeydown = function(){  
    if(window.event && window.event.keyCode == 116){ 
     window.event.keyCode = 505;  
    } 
    if(window.event && window.event.keyCode == 505){  
     return false;     
    }  
}

function doMethod(methodName){
    document.forms[0].method.value=methodName
    document.forms[0].submit()
}
//**********************************************

function maximize(){
  if (window.screen) {
    var aw = screen.availWidth;
    var ah = screen.availHeight;
    window.moveTo(0, 0);
    window.resizeTo(aw, ah);
  }
}

//**********************************************
function ir_pagina(objeto, tipo_pagina, pagina, ruta) {
	with(objeto) {
         objeto.target="";
		if (tipo_pagina=="S") 	hid_pagina.value = pagina
		if (tipo_pagina=="A") 	hid_pagina.value = pagina
		if (tipo_pagina=="N") 	hid_pagina.value = cmb_paginacion.value;
		action = ruta;
		submit();		
	}
}

//***********************************************
function check_all(form)  {
	for(i=0 ; i<form.elements.length; i++)	{ 
		if(form.elements[i].type == "checkbox")	
             form.elements[i].checked = (form.elements[i].checked) ? false : true;
	}
}
//***********************************************
 function valida_numero(xinput,tipval)
  {
    var xkey=event.keyCode;
	if(tipval=="int")
		if ((xkey < 48) || (xkey > 57)) event.returnValue = false;
	if(tipval=="dec")
		{ if ((xkey < 46) || (xkey > 57)) event.returnValue = false;
                  }  

    
                 
	if(tipval=="str")
		if (((xkey != 32) && (xkey < 65)) || ((xkey > 90) && (xkey < 97))) event.returnValue = false;
	if(tipval=="tlf")
		if (((xkey != 32) && (xkey < 45)) || (xkey > 57)) event.returnValue = false;
		
	if (tipval=="afn")	
	 { if (  ((xkey != 32) && (xkey < 45))  || (xkey > 57)   ||
	           ((xkey < 48) || (xkey > 57))   )   event.returnValue = false;
 	  }
		
  }
function getDecimalFormat(valor)
 {var tokens,entero,decimal,strValor
  strValor = new String(valor)
  tokens =StringTokenizer(strValor,'.')
  if(tokens.length>1)
   {entero  = tokens[0]
    decimal = tokens[1]
	tokens[0]=entero+"."+decimal.substring(0,2)
   }
  else{
     tokens[0] = tokens[0]+".00"
  }
  return tokens[0] 	
 }
 
function StringTokenizer(cad, delim)
 {var cads = new Array();
  var n = cad.length;
  var j = 0;
  var ic = 0;
  for (i=0;i<n;i++)
   {if ( cad.charAt(i)==delim )
     {cads[j] = cad.substring(ic, i); ic = i+1; j++;}
   }
  cads[j] = cad.substring(ic, n);
  return cads;
}
/*
function cuentaCaracteres(objText,total,numContador){
	if (objText.value.length>total){
		objText.value = objText.value.substring(0,total);
	}
	else{
	caja = eval ("document.forms[0].contador"+numContador);
	caja.value =objText.value.length+1;
	}
}*/

function cuentaCaracteres(objText,total,numContador){
	if (objText.value.length>total){
		objText.value = objText.value.substring(0,total);
	}
	else{
            caja = eval ("document.forms[0].contador"+numContador);
            if(caja){
                if(objText.value==""){
                    caja.value="0";
                }else{

                    caja.value =objText.value.length;
                }
            }
	}
}
//***********************************************
//Llama a los PDF de Ayuda
	function ayuda(){  
   var url="mostrarAyuda.do?";
   window.open(url,"Ayuda","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,top=0,left=0,width=0,height=0");
     }            
     
      
     
function calendario2(nom_campo, formato) {   
var matParam = new Array(3);
matParam[0] = window;
matParam[1] = nom_campo;
matParam[2] = formato;
window.showModalDialog('ventanaCalendario.htm',matParam,'dialogHeight:214px; dialogWidth:280px;center:yes; help:no; resizable:no; status:no');
}

function soloEnteros(e){
	var keynum;
	var keychar;
	var numcheck;
	
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	if((keynum == 8) || (keynum == undefined)){
		return true;
	}
	keychar = String.fromCharCode(keynum);
	numcheck = /[0-9]/;
	return numcheck.test(keychar);
}

//valida solo letras con espacio
function validarLetras(e) {
	tecla = (document.all) ? e.keyCode : e.which;
	if (tecla==8) return true;
	patron =/^([a-z\xc0-\xff\s]+)$/i;
	te = String.fromCharCode(tecla);
	return patron.test(te);
}






